package org.chispa.api.query;

import org.chispa.api.util.BadSyntaxException;
import org.chispa.api.util.NoSuitableVisitorException;
import org.chispa.api.visitors.ParamVisitor;

import com.google.common.annotations.VisibleForTesting;

@VisibleForTesting
public class SimpleParamWrapper<T,R,S> implements ParamWrapper<T,R,S> { 
	
	protected T param;
	
	public SimpleParamWrapper(T param)
	{
		this.param=param;
	}
	
	@Override
	public T getWrappedParam() {
		return param;
	}

	@Override
	public R acceptHash(ParamVisitor<T, R, S> visitor)
			throws NoSuitableVisitorException, BadSyntaxException {
		try
		{
			return visitor.visitHash(this);
		}
		catch(Exception e){
			throw new NoSuitableVisitorException(e);
		}
	}

	@Override
	public S acceptEnc(ParamVisitor<T, R, S> visitor)
			throws NoSuitableVisitorException {
		return visitor.visitEncrypt(this);
	}

}
